package cn.wolfcode.luowowo.comment.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 景点评论
 */
@Setter
@Getter
@Document("Scenic_comment")  //文档名称
public class ScenicComment implements Serializable {
    @Id //文档id
    private String id;  //mongodb默认的是id
    private Long detailId;  //景点(明细)id
    private String detailTitle; //景点标题
    private Long userId;    //用户id
    private String username;  //用户名
    private String city; //用户所在城市
    private int level;   //级别
    private String headUrl;     //头像
    private Date createTime;    //创建时间
    private String content;      //评论内容
    private int thumbupnum;     //点赞数

    private String commentUrl;//景点图片

    private List<String> commentUrls = new ArrayList<>();//景点图片

    private List<Long> thumbuplist = new ArrayList<>(); //点赞用户的id集合

    //从数据库拿出的图片字符转分割成换成string数组,再遍历出每一个string图片,再装到list 集合 方便做页面图片回显;
    public List<String> getCoverUrls() {
        String[] coverUrls = commentUrl.split(",");
        for (String c : coverUrls) {

            commentUrls.add(c);
        }
        return commentUrls;
    }
}
